package cn.tedu.review;

import java.io.File;
import java.io.IOException;

/**本类用于复习File类*/
public class TestFile {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\kaifa\\ready\\1.txt");
        System.out.println(file.length());
        System.out.println(file.exists());
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
        System.out.println(file.getName());
        System.out.println(file.getParent());
        System.out.println(file.getAbsoluteFile());

        File file2 = new File("C:\\kaifa\\ready\\2.txt");
        System.out.println(file2.createNewFile());

        File file3 = new File("C:\\kaifa\\ready\\b");
        System.out.println(file3.mkdir());//单层文件夹的创建

        File file4 = new File("C:\\kaifa\\ready\\m\\n\\o");
        System.out.println(file4.mkdirs());//多层文件夹的创建

        file2.delete();//2.txt文件被删除
        file3.delete();//b文件夹被删除
        file4.delete();//空文件夹o被删除

        File file5 = new File("C:\\kaifa\\ready");
        String [] list = file5.list();
        File[] fs = file5.listFiles();
        System.out.println(fs[0].length());

    }
}
